package com.wenhai.spring.aop.features;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * AspectJ 演示
 *
 * @author wenhai
 * @date   2021/3/4
 */
@ComponentScan("com.wenhai.spring.aop.features")
@EnableAspectJAutoProxy(exposeProxy = true)
public class AspectJAnnotatedPointcutDemo {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.register(AspectJAnnotatedPointcutDemo.class);
        ctx.refresh();
        ctx.getBean(AspectJAnnotatedPointcutDemo.class).execute();
        ctx.close();
    }

    public void execute() {
        System.out.println("execute().... ");
//        ((AspectJAnnotatedPointcutDemo) AopContext.currentProxy()).execute2();
        execute2();
    }

    public void execute2() {
        System.out.println("execute2().... ");
    }
}
